package com.liusha.quicksand.dao;

import com.liusha.quicksand.po.Comment;
import com.liusha.quicksand.po.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 一世长安一世欢
 * @Date: 2020/10/24
 * @Time: 1:39
 * @Description: No Description
 */
public interface UserRepository extends JpaRepository<User,Long> {

    @Query("select u from User u where username like ?1 or nickname like ?1 or tel like ?1 or email like ?1")
    public Page<User> findByKeyWord(String kw, Pageable pageable);

    @Query("update User u set u.password=?1 where u.userId=?2")
    public void modifyPassword(String password,Long userId);

    //通过账号查询用户信息，获取唯一用户
    public Optional<User> findByUsername(String username);

}
